package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class SortString {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("jack");
        list.add("rose");
        list.add("tom");
        list.add("jerry");
        list.add("black");
        list.add("kobe");
        System.out.println("list原始数据:  "+list);
        Collections.sort(list);
        System.out.println("list排序后:"+list);

        List<String> list2 = new ArrayList<>();
        list2.add("jack");
        list2.add("rose123412341234");
        list2.add("tom213");
        System.out.println("list2原始数据:  "+list2);
        list2.sort((s1,s2)->s1.length()-s2.length());
        System.out.println("list2排序后:"+list2);
    }
}
